/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package action;

import DAO.Constantes;
import DAO.DAO_Articulo;
import DAO.DAO_Autor;
import DAO.DAO_EstadoArticulo;
import actionForm.AnadirArticuloActionForm;
import actionForm.ModificarAutorActionForm;
import clases.Articulo;
import clases.Autor;
import clases.EstadoArticulo;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 *
 * @author Rafa
 */
public class AceptarArticuloAction extends org.apache.struts.action.Action {

    /* forward name="success" path="" */
    private static final String SUCCESS = "success";
    private static final String CANCEL = "cancel";
    private static final String MODIFICAR = "modificar";
    private static final String FAILURE = "failure";

    /**
     * This is the action called from the Struts framework.
     *
     * @param mapping The ActionMapping used to select this instance.
     * @param form The optional ActionForm bean for this request.
     * @param request The HTTP Request we are processing.
     * @param response The HTTP Response we are processing.
     * @throws java.lang.Exception
     * @return
     */
    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        if (isCancelled(request)) {
            return mapping.findForward(CANCEL);
        } else {

            AnadirArticuloActionForm formulario = (AnadirArticuloActionForm) form;
            
            int idArticulo = formulario.getIdArticulo();
            

            /*Se pone tambien en request la lista de usuarios libres para que esten 
             disponibles al añadir una nueva seccion o modificar una seccion*/
            DAO_Articulo daoArticulo = new DAO_Articulo();
            
            //Articulo articulo =daoArticulo.consultaArticulo(idArticulo, true);
            
            //DAO_EstadoArticulo daoEstado= new DAO_EstadoArticulo();
            
            daoArticulo.modificaEstadoArticulo(idArticulo,Constantes.getART_EN_MAQUETACION(), true);
            
            //formulario.setEstado(revision);
                
                                        
                   
                    return mapping.findForward(SUCCESS);
                }
            }
        }

    

